import 'package:ac/data/ac_user_manager.dart';
import 'package:ac/model/ac_blogger_model.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';

import 'ac_my_posts_state.dart';

class AcMyPostsLogic extends GetxController {
  final AcMyPostsState state = AcMyPostsState();
  final postList = <Post>[].obs;

  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();
    initData();
  }

  void initData() {
    postList.value = AcUserManager.getPublishPost();
  }

  void deletePost(Post item) async{
    EasyLoading.show(status: 'deleting...', maskType: EasyLoadingMaskType.black);
    await Future.delayed(const Duration(milliseconds: 1300), () {});
    AcUserManager.deletePost(item);
    postList.remove(item);
    EasyLoading.dismiss();
  }
}
